package cn.javass.dp.iterator.example3;

public class ArrayIteratorImpl implements Iterator {

    private SalaryManager salaryManager;

    private int index = -1;

    public ArrayIteratorImpl(SalaryManager salaryManager) {
        this.salaryManager = salaryManager;
    }

    @Override
    public void first() {
        index = 0;
    }

    @Override
    public void next() {
        if (index < salaryManager.size()) {
            index = 1 + index;
        }
    }

    @Override
    public boolean isDone() {
        if (index == salaryManager.size()) {
            return true;
        }
        return false;
    }

    @Override
    public Object currentItem() {
        return salaryManager.get(index);
    }
}
